﻿/* 
* -----------------------------------------------------------------------------------
*	Component       : ModelController
*	Source file     : AcountController.cs
*	Author          : HungNguyen
*	Creation Date   : 01.29.2013
*	Description     : This file describes about functions for account of system
*	Use Case        : 
*	Includes        : 
*	Notes           : 
*	Copyright HKSoft, Inc. 2013
*	The copyright to the computer program(s) herein is the property of Prowess, Inc. 
*	The program(s) may be used and/or copied only with the written permission of HKSoft, Inc. 
*	or in accordance with the terms and conditions stipulated in the 
*	agreement/contract under which the program(s) have been supplied.
* -----------------------------------------------------------------------------------
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.DataModel;
using QLBH.Base;

namespace QLBH.Model.Controller
{
    public class AcountController:QLBHEntityBase<ACOUNT>
    {
        public static AcountController GetInstance()
        {
            return new AcountController();
        }
        public override ACOUNT Add(ACOUNT entity)
        {
            return base.Add(entity);
        }
        public override ACOUNT Edit(ACOUNT entity)
        {
            return base.Edit(entity);
        }
        public bool CheckValidUserName(String userName)
        {
            return FindBy(un => un.UserName == userName).FirstOrDefault() == null;
        }
        public ACOUNT CheckAcount(String userName, String pass)
        {
            try
            {
                byte[] password = MD5Helper.GetMD5(pass);
                ACOUNT ac = FindBy(un => un.UserName == userName && un.Pass == password).FirstOrDefault();
                return ac;
            }
            catch (System.Exception ex)
            { 
                throw ex;
            }
            
        }
        
    }
}
